#pragma once

#include "isingleton.h"
#include "Application.h"
#include "ClockListener.h"
#include "ClockSource.h"
#include "MouseListener.h"
#include "Window.h"
#include "event.h"

typedef struct IDirectInputDevice8 *LPDIRECTINPUTDEVICE8;

struct MouseEvent
{
public:
	int x,y;
	bool left,middle,right,key4;

};
class MouseSource :
	public Source<MouseSource,MouseListener,MouseEvent>,public ISingleton<MouseSource,Window>,public Clock::ClockListener
{
	LPDIRECTINPUTDEVICE8 lpMouse;
	MouseEvent m;
	int m_up,m_down,m_left,m_right;
public:
	MouseEvent& getEvent();
	MouseSource(Window& win);
	virtual void OnClock(Clock::ClockListener::SourceType& t);
	void SetMousePosition(int x,int y)
	{
		m.x=x;m.y=y;
	}
	void SetMouseBoundary(int up,int down, int left, int right)
	{
		m_up=up;
		m_down=down;
		m_left=left;
		m_right=right;
	}
public:
	~MouseSource(void);
};
